package com.hengpeng.itfinbase.persist;

import java.util.Date;
import java.util.Map;

import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.Lob;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.hengpeng.common.persist.entity.AbstractEntity;
import com.hengpeng.common.web.annotation.HtmlInput;
import com.hengpeng.common.web.annotation.HtmlInputType;
import com.hengpeng.itfinbase.CacheType;

@Entity
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, region = CacheType.SECOND_CACHE_DEFAULT)
public class Partner extends AbstractEntity
{

	/**
	 * <pre>
	 * 合作商状态
	 * </pre>
	 * @author zhaojitao
	 * @version 1.0, 2011-8-16
	 */
	public static enum PartnerStatus
	{
		/**
		 * 关闭
		 */
		CLOSED("关闭"),
		/**
		 * 打开
		 */
		OPEN("打开");

		private String text;

		PartnerStatus(String text)
		{
			this.text = text;
		}

		public String getText()
		{
			return text;
		}

		public void setText(String text)
		{
			this.text = text;
		}
	}

	public enum PartnerType
	{
		/**
		 * 支付宝提现网关
		 */
		CHINAPNR("汇付天下"),

		/**
		 * 资金池模式
		 */
		FUND("资金池");

		private String text;

		PartnerType(String text)
		{
			this.text = text;
		}

		public String getText()
		{
			return text;
		}

		public void setText(String text)
		{
			this.text = text;
		}

	}

	private static final long serialVersionUID = 362771152230299815L;

	/**
	 * 合作商编号
	 */
	@Id
	@Column(length = 20)
	@HtmlInput(label = "合作商编号", maxLength = 20, type = HtmlInputType.ID, index = 1, nullable = false)
	private String id;

	@HtmlInput(label = "商户号", type = HtmlInputType.TEXT, index = 7, nullable = true)
	@Column(length = 20)
	private String merchantId;

	/**
	 * 合作商私钥
	 */
	@Lob
	@HtmlInput(label = "合作商私钥", maxLength = 20, type = HtmlInputType.TEXT, index = 2, nullable = false)
	private String privateKey;

	/**
	 * 合作商公钥
	 */
	@Lob
	@HtmlInput(label = "合作商公钥", maxLength = 20, type = HtmlInputType.TEXT, index = 2, nullable = false)
	private String publicKey;

	@Column(length = 50)
	@HtmlInput(label = "合作商名称", maxLength = 20, type = HtmlInputType.TEXT, index = 3, nullable = false)
	private String name;

	/**
	 * 合作商状态
	 */
	@Column(length = 10)
	@Enumerated(javax.persistence.EnumType.STRING)
	@HtmlInput(label = "合作商状态", type = HtmlInputType.SELECT, index = 4, nullable = false, labelProperty = "text")
	private PartnerStatus status;

	@Column(length = 20)
	@HtmlInput(label = "资金服务商类型", type = HtmlInputType.SELECT, index = 3, nullable = false, labelProperty = "text")
	@Enumerated(javax.persistence.EnumType.STRING)
	private PartnerType partnerType;

	@ElementCollection(fetch = FetchType.EAGER)
	@HtmlInput(label = "额外配置信息", maxLength = 500, type = HtmlInputType.TEXTAREA, index = 99, nullable = true, inputId = "extConfigString")
	private Map<String, String> extConfigs;

	@HtmlInput(label = "接口地址", type = HtmlInputType.TEXT, index = 10, nullable = false)
	@Column(length = 200)
	private String gateWayUrl;

	@Column(length = 1000)
	@HtmlInput(label = "描述", type = HtmlInputType.TEXT, index = 20, nullable = true)
	private String remark;

	/**
	 * 创建时间
	 */
	@HtmlInput(label = "创建时间", type = HtmlInputType.LABEL, index = 5, nullable = true)
	private Date createTime;

	/**
	 * 更新时间
	 */
	@HtmlInput(label = "更新时间", type = HtmlInputType.LABEL, index = 5, nullable = true)
	private Date updateTime;

	public Date getCreateTime()
	{
		return createTime;
	}

	public String getId()
	{
		return id;
	}

	public String getName()
	{
		return name;
	}

	public PartnerStatus getStatus()
	{
		return status;
	}

	public void setCreateTime(Date createTime)
	{
		this.createTime = createTime;
	}

	public void setId(String id)
	{
		this.id = id;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public void setStatus(PartnerStatus status)
	{
		this.status = status;
	}

	public String getMerchantId()
	{
		return merchantId;
	}

	public void setMerchantId(String merchantId)
	{
		this.merchantId = merchantId;
	}

	public PartnerType getPartnerType()
	{
		return partnerType;
	}

	public void setPartnerType(PartnerType partnerType)
	{
		this.partnerType = partnerType;
	}

	public Map<String, String> getExtConfigs()
	{
		return extConfigs;
	}

	public void setExtConfigs(Map<String, String> extConfigs)
	{
		this.extConfigs = extConfigs;
	}

	public String getRemark()
	{
		return remark;
	}

	public void setRemark(String remark)
	{
		this.remark = remark;
	}

	public Date getUpdateTime()
	{
		return updateTime;
	}

	public void setUpdateTime(Date updateTime)
	{
		this.updateTime = updateTime;
	}

	public String getPrivateKey()
	{
		return privateKey;
	}

	public void setPrivateKey(String privateKey)
	{
		this.privateKey = privateKey;
	}

	public String getPublicKey()
	{
		return publicKey;
	}

	public void setPublicKey(String publicKey)
	{
		this.publicKey = publicKey;
	}

	public String getGateWayUrl()
	{
		return gateWayUrl;
	}

	public void setGateWayUrl(String gateWayUrl)
	{
		this.gateWayUrl = gateWayUrl;
	}

}
